perm filename CALLER.2[EAL,HE]3 blob sn#708030 filedate 1983-04-22 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00004 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	{$NOMAIN	Overlay-transfer calls }
C00004 00003	{ External routines defined elsewhere: }
C00006 00004	procedure i1bPpReal(r: real)  external
C00011 ENDMK
C⊗;
{$NOMAIN	Overlay-transfer calls }

{ These are to be used when an overlay needs to call another overlay which
  occupies the same virtual address space; i.e. the called overlay will replace
  the calling overlay.  The calling overlay needs to be re-read into memory
  before control can be returned to it.  To accomplish this, a routine in CALLER
  is called, the called overlay is read in and executed, and control is returned
  to CALLER; the calling overlay is then restored and control returned to it.

  Notice that all the pointer-type definitions are faked.
}

type
  ascii = char; 

  statementp = ↑integer;
  pdbp = ↑integer;
  varidefp = ↑integer;
  enventryp = ↑integer;

  cstring = packed array [1..10] of ascii;
  c4str = packed array [1..4] of ascii;
  c5str = packed array [1..5] of ascii;
  c20str = packed array [1..20] of ascii;
  linestr = packed array [1..130] of ascii;


{ External routines defined elsewhere: }

	(* From PP *)
procedure ppReal(r: real); 					external;

	(* From IMAIN *)
procedure interp(dLev: integer);				external;

	(* From EEDITS *)
procedure editStmnt;						external;

	(* From EADDST *)
procedure addStmnt(firstTime: boolean);				external;

	(* From IAUX2A *)
procedure killVar(e: enventryp);				external;

	(* From IFLUSH *)
procedure flushAll(p: pdbp; dLev: integer);			external;

	(* From EDEBUG *)
procedure executeStmnt(st: statementp; which: integer);		external;

	(* Routines used to re-call overlays *)
procedure iAux1bGet;						external;
procedure pTokGet;						external;
procedure pAux1Get;						external;
procedure eAux2aGet;						external;
procedure eAux3aGet;						external;
procedure eAux3bGet;						external;
procedure em3Get;						external;
procedure em4Get;						external;
procedure em6Get;						external;
procedure eDbgGet;						external;

procedure i1bPpReal(r: real);  external;
procedure i1bPpReal; 
  begin ppReal(r); iAux1bGet end;

procedure e2akillVar(e: enventryp); external;
procedure e2akillVar;
  begin killVar(e); eAux2aGet; end;


{ For e3aInterp, here is the chain of events that led to this call:
	Either edit main or readProg calls makeOuterBlock
	Either makeOuterBlock or readProg calls setUpStmnt
	setUpStmnt calls initOuterBlock
	initOuterBlock calls Interp
  So when Interp exits, we need to re-call the appropriate overlays in
  each of the co-trees.  In either case, we need to re-read EAUX3A, since
  that's where initOuterBlock is.  It will work if we just read in EMAIN3,
  since reading in a subtree calls in the root tree also.
}
	
procedure e3aInterp(dLev: integer); external;
procedure e3aInterp;	
  begin 
  Interp(dLev); 	{Start by calling interpreter; let it do its thing}
  eAux3aGet;		{and the level 3 one that contains setUpStmnt}
  em3Get;		{Call in EMAIN3 overlay (contains readProg) }
  end;			{That ought to do it}


procedure e3aFlushAll(p: pdbp; dLev: integer); external;
procedure e3aFlushAll; 
  begin flushAll(p, dLev); eAux3aGet end;

procedure edbInterp(dLev,which: integer); external;
procedure edbInterp;
  begin 
  Interp(dLev); 		{Go and interpret it}
  eDbgGet;			{Re-read the EDEBUG overlay that called us}
  if which=3 then em3Get	{Now who called EDEBUG? It's one of the MAINn ones}
   else if which=4 then em4Get
   else if which=6 then em6Get
   else begin writeln('Loss in edbInterp: ',which:1); break(output) end;
  end;

procedure em6EditStmnt; external;
procedure em6EditStmnt;
begin editStmnt; em6Get end;

procedure emAddStmnt(firstTime: boolean; which: integer); external;
procedure emAddStmnt; 
  begin
  addStmnt(firstTime);		{Go ahead and call in EADDST and do it}
  if which=4 then em4Get	{Now re-read the right overlay}
   else if which=6 then em6Get	
   else if which=3 then
    begin			(* XX Rick - this is a rough guess XX *)
    eAux3aGet;				{Re-read the calling overlay}
    em3Get;				{readProg was called by EMAIN3}
    end
   else begin writeln('Loss in emAdd: ',which:1); break(output) end;
  end;

procedure ea3bXecuteStmnt(st: statementp; which: integer); external;
procedure ea3bXecuteStmnt;
  begin executeStmnt(st,which); eAux3bGet end;